/*
 * GenericKey.cpp
 *
 *  Created on: Oct 25, 2013
 *      Author: carlos
 */

#include "GenericKey.h"
#include <iostream>
#include "../../utils/StringUtils.h"
GenericKey::GenericKey() {

}

GenericKey::~GenericKey() {
}

std::string GenericKey::serialize() {
	Serializacion s;
	s.addString(this->realKey);
	return s.toString();
}

void GenericKey::unserialize(std::string& buffer) {
	Serializacion s(buffer);
	this->realKey = s.getString();

}

GenericKey::GenericKey(Key key) {
	this->realKey = StringUtils::idToString(key);
}

GenericKey::GenericKey(ID id) {
	this->realKey = StringUtils::idToString(id);
}
GenericKey::GenericKey(int id) {
	this->realKey = StringUtils::idToString(id);
}

GenericKey::GenericKey(string realKey) {
	this->realKey = StringUtils::toLower(realKey);
}

GenericKey::GenericKey(const GenericKey& genericKey) {
	this->realKey = genericKey.realKey;
}

GenericKey::GenericKey(const GenericKey* genericKey) {
	if (genericKey != NULL) {
		this->realKey = genericKey->realKey;
	}

}

ostream& operator<<(ostream& myOstream, const GenericKey& genericKey) {
	myOstream << "Key> " << genericKey.getRealKey()<< " ";
	return myOstream;
}

